﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;

namespace Black.SurfaceToolkit.Effects
{
    /// <summary>
    /// InvertColorEffect Effect
    /// </summary>
    public class InvertColorEffect : ShaderEffect
    {
        #region Propriétées de dépendances

        /// <summary>
        /// Gets or sets the Input of the shader.
        /// </summary>
        public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(InvertColorEffect), 0);

        #endregion

        #region Accesseurs

        /// <summary>
        /// Affecte ou retourne la propriété Input du Shader
        /// </summary>
        [System.ComponentModel.BrowsableAttribute(false)]
        public Brush Input
        {
            get
            {
                return ((Brush)GetValue(InvertColorEffect.InputProperty));
            }
            set
            {
                this.SetValue(InvertColorEffect.InputProperty, value);
            }
        }

        #endregion

        #region Variables statiques

        /// <summary>
        /// The shader instance.
        /// </summary>
        private static readonly PixelShader _PixelShader;

        #endregion

        #region Constructors

        /// <summary>
        /// Creates an instance of the shader from the included pixel shader.
        /// </summary>
        static InvertColorEffect()
        {
            InvertColorEffect._PixelShader = new PixelShader();
            InvertColorEffect._PixelShader.UriSource = new Uri("pack://application:,,,/Black.SurfaceToolkit;component/Effects/Shaders/InvertColor.ps");
        }

        /// <summary>
        /// Creates an instance and updates the shader's variables to the default values.
        /// </summary>
        public InvertColorEffect()
        {
            this.PixelShader = InvertColorEffect._PixelShader;

            this.UpdateShaderValue(InvertColorEffect.InputProperty);
        }

        #endregion
    }
}
